package com.muqi.app.user.widget;

import com.muqi.app.qlearn.student.R;

import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

public class MineEntry extends RelativeLayout {

	private ImageView icon;
	private TextView title;

	private String title_s;  
    private Drawable icon_s;  
	
	public MineEntry(Context context) {
		super(context);
		init(context,null);
	}

	public MineEntry(Context context, AttributeSet attrs) {
		super(context, attrs);
		init(context,attrs);
	}

	public MineEntry(Context context, AttributeSet attrs, int defStyleAttr) {
		super(context, attrs, defStyleAttr);
		init(context,attrs);
	}

	private void init(Context context,AttributeSet attrs) {
		
		LayoutInflater inflater = LayoutInflater.from(context);
		View view = inflater.inflate(R.layout.mine_entry, this);
		icon = (ImageView) view.findViewById(R.id.icon);
		title = (TextView) view.findViewById(R.id.text);

		 // 通过上下文context获取自定义属性  
        TypedArray typeArr = context.obtainStyledAttributes(attrs,R.styleable.MineEntry);  
        // 获取在xml文件中,自定义属性的值  
        title_s = typeArr.getString(R.styleable.MineEntry_entry_name); 
        icon_s = typeArr.getDrawable(R.styleable.MineEntry_icon);
        //释放资源  
        typeArr.recycle();  
        // 设置title  
        setTitle(title);
        setIcon(icon);
        
	}

	private void setIcon(ImageView icon2) {
		icon2.setImageDrawable(icon_s);
	}

	private void setTitle(TextView title2) {
		title2.setText(title_s);
	}
	
}
